package 极客算法训练营.chapter10;

import java.util.Arrays;

public class 分发饼干 {
    class Solution {
        public int findContentChildren(int[] g, int[] s) {
            Arrays.sort(g);
            Arrays.sort(s);
            int count = 0;
            int flag = 0;
            for (int i = 0; i < g.length; i++) {
                while (flag < s.length && g[i] > s[flag]) {
                    flag++;
                }
                if (flag >= s.length) return count;
                count++;
                flag++;
            }
            return count;
        }
    }
}
